package com.heima.model.article.controller.v1;

import com.heima.model.article.service.ArticleService;
import com.heima.model.common.apArticle.dato.ArticleHomeDto;
import com.heima.model.common.apArticle.pojos.ArticleConstants;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    /**
     * 根据参数加载文章列表
     * @param
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    }

    /**
     * 保存文章内容+文章配置+文章信息
     * @param dto
     * @return
     */
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    }
    /**
     * 保存文章内容+文章配置+文章信息
     * @param dto
     * @return
     */
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,dto);
    }
}
